package com.yupi.yuoj.controller;

import com.yupi.yuoj.service.QuestionThumbService;
import com.yupi.yuoj.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 题目提交接口
 */
@RestController
//@RequestMapping("/question_thumb")
@Slf4j
@Deprecated
public class QuestionThumbController {

    @Resource
    private QuestionThumbService questionThumbService;

    @Resource
    private UserService userService;

    /**
     * 提交代码
     *
     * @param questionThumbAddRequest
     * @param request
     * @return
     */
//    @PostMapping("/question_submit/do")
//    public BaseResponse<Long> doThumb(@RequestBody QuestionThumbAddRequest questionThumbAddRequest,
//                                      HttpServletRequest request) {
//        if (questionThumbAddRequest == null || questionThumbAddRequest.getQuestionId() <= 0) {
//            throw new BusinessException(ErrorCode.PARAMS_ERROR);
//        }
//        final User loginUser = userService.getLoginUser(request);
//        Long result = questionThumbService.doQuestionThumb(questionThumbAddRequest, loginUser);
//        return ResultUtils.success(result);
//    }
//
//    /**
//     * 用户获取提交列表
//     *
//     * @return
//     */
//    @PostMapping("/question_submit/list/page")
//    public BaseResponse<Page<QuestionSubmmitVO>> listQuestionByPage(@RequestBody QuestionSubmmitQueryRequest questionSubmmitQueryRequest, HttpServletRequest request) {
//        long current = questionSubmmitQueryRequest.getCurrent();
//        long size = questionSubmmitQueryRequest.getPageSize();
//        User loginUser = userService.getLoginUser(request);
//        Page<QuestionThumb> questionSubmmitPage = questionThumbService.page(new Page<>(current, size),
//                questionThumbService.getQueryWrapper(questionSubmmitQueryRequest, loginUser));
//        Page<QuestionSubmmitVO> questionSubmmitVOPage = new Page<>();
//        questionSubmmitVOPage.setPages(size);
//        questionSubmmitVOPage.setCurrent(current);
//        List<QuestionThumb> questionPageRecords = questionSubmmitPage.getRecords();
//        questionSubmmitVOPage.setRecords(questionPageRecords.stream().map(x -> {
//            return questionThumbService.getQuestionSubmmitVo(x, loginUser);
//        }).collect(Collectors.toList()));
//        return ResultUtils.success(questionSubmmitVOPage);
//    }
}
